<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        :permission="permissionList"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
      >
        <template slot="menuLeft">
          <el-button type="primary" size="small" @click="handleExport">导出</el-button>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
  import { fetchList, getObj, addObj, putObj, delObj, exportExcel } from '@/api/subwaystm/swstconductorselldetail'
  import { tableOption,startDate, endDate } from '@/const/crud/subwaystm/swstconductorselldetail'
  import { handleExcelResponse } from '@/util/util'
  import { mapGetters } from 'vuex'
  import baseCrud from '@/mixins/base-crud'

  export default {
    name: 'swstconductorselldetail',
    mixins: [baseCrud('subwaystm/swstconductorselldetail')],
    data() {
      return {
        searchForm: {
          dates1: [startDate, endDate]
        }
      }
    },
    computed: {
      ...mapGetters(['permissions']),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permissions.swstconductorselldetail_add, false),
          delBtn: this.vaildData(this.permissions.swstconductorselldetail_del, false),
          editBtn: this.vaildData(this.permissions.swstconductorselldetail_edit, false)
        };
      }
    },
    methods: {
      async handleExport(){
        let loading = this.$loading({
          lock: true,
          text: "Loading",
          spinner: "el-icon-loading",
          background: "rgba(0, 0, 0, 0.7)"
        })
        try {
          let tableSelect = this.$refs.crud.tableSelect;
          let ids = tableSelect.map(row => row.id)
          let param = {
            ids: this.validatenull(ids)?null:ids
          };
          const res = await exportExcel(param);
          handleExcelResponse(res);
        } finally {
          loading.close();
        }
      },
      // handleExport(){
      //   let query = Object.assign({
      //     current: this.page.currentPage,
      //     size: this.page.pageSize
      //   }, this.searchForm)
      //   exportExcel(query).then(response => {
      //     handleExcelResponse(response)
      //   })
      // }
    }
  }
</script>
